import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/auto_makers/shop_home/order_details/order_info.dart';
import 'package:ytbusiness/page/auto_makers/shop_home/order_widget/enquiry_item.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';
class AutoAwaitPay extends StatefulWidget {
  @override
  _AutoAwaitPayState createState() => _AutoAwaitPayState();
}

class _AutoAwaitPayState extends State<AutoAwaitPay> {
  List<String> typeList = ["原厂原包","品牌","拆车","OEM"];
  bool isShow = false;//默认隐藏
  int checkIndex = 0; //当前选中索引
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: (){
        //输入框失焦
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Scaffold(
        backgroundColor: YTStyle.bgColor,
        appBar: AppBar(
          elevation:0,
          centerTitle: true,
          backgroundColor: Colors.white,
          title: Text("等待付款",style: TextStyle(color: Color(0xff323232),fontSize: setSp(18),fontWeight: FontWeight.w600),maxLines: 1,overflow: TextOverflow.ellipsis,),
          leading: GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: (){
              Navigator.pop(context);
            },
            child: Row(
              children: [
                Container(
                    margin: EdgeInsets.only(left: setWidth(15)),
                    width: setWidth(10),
                    height: setWidth(17),
                    child: Image.asset("assets/images/return.png",fit: BoxFit.cover,)
                ),
              ],
            ),
          ),
        ),
        body: CustomScrollView(
          slivers: [
            SliverToBoxAdapter(
              child: OrderInfo(),
            ),
            SliverToBoxAdapter(
              child: Container(
                padding: EdgeInsets.only(bottom: setWidth(10),top: setWidth(10)),
                color: Colors.white,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    link(image: "blue_kefu.png",title: "在线联系",phone: "10086"),
                    link(image: "blue_phone_link.png",title: "电话联系",phone: "10086"),
                  ],
                ),
              ),
            ),
            SliverToBoxAdapter(
              child: Container(
                margin: EdgeInsets.only(top: setWidth(15)),
                padding: EdgeInsets.only(top: setWidth(18),left: setWidth(15),bottom: setWidth(13)),
                decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border(bottom:BorderSide(color: Color(0xffF0F0F0),width: setWidth(0.5)) )
                ),
                child: Text("询价信息",style: TextStyle(color: Color(0xff323232),fontSize: setSp(15),fontWeight: FontWeight.w600),),
              ),
            ),
            SliverList(delegate: SliverChildBuilderDelegate((context,index){
              return EnquiryItem(
                checkIndex: checkIndex,
                onCheckUpdate: (value){
                  print(value);
                },
              );
            },
              childCount: 3,
            )),
            //放弃列表
            SliverList(
                delegate: SliverChildBuilderDelegate(
                      (context, index) {
                    return EnquiryItem(
                      checkIndex: checkIndex,
                      onCheckUpdate: (value){
                        print(value);
                      },
                    );
                  },
                  childCount: isShow?(typeList.length >0 ? typeList.length:0):0,
                )),
            //隐藏显示
            SliverToBoxAdapter(
              child: GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: (){
                  setState(() {
                    isShow = !isShow;
                  });
                },
                child: Container(
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(bottom: setWidth(12)),
                  padding: EdgeInsets.only(
                      top: setWidth(12),
                      bottom: setWidth(12)),
                  color: Colors.white,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                        child: Text(
                          isShow?"隐藏未报价的${typeList.length-1}个商品":"已隐藏未报价的${typeList.length-1}个商品",
                          style: TextStyle(
                              color: Color(0xff989898),
                              fontSize: setSp(14)),
                        ),
                      ),

                      Container(
                        margin: EdgeInsets.only(left: setWidth(6),right: setWidth(6)),
                        child: Text(
                          isShow?"收起": "展开",
                          style: TextStyle(
                              color: Color(0xff989898),
                              fontSize: setSp(14),
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                      SizedBox(width: setWidth(12),
                        height: setWidth(6),
                        child: Image.asset(isShow?"assets/images/shouqi.png":"assets/images/zhankai.png",width: setWidth(12),
                          height: setWidth(6),fit: BoxFit.cover,),
                      ),

                    ],
                  ),
                ),
              ),
            ),

            //结算信息
            SliverToBoxAdapter(
              child: settlementInfo(price:"1259.00",serve: "3280.00",sum: "1259.00"),
            ),
            SliverToBoxAdapter(
              child: SizedBox(
                height: setWidth(30),
              ),
            ),

          ],
        ),

      ),
    );
  }

}
